<template>
	<view class="">
		<!-- 状态栏 -->
		<view class="status_bar">
		</view>
		<view class="home-index">
			<view class="logo">
				<image src="../../static/images/mn5.jpg" mode=""></image>
				<view class="desc">
					应急融合通信平台
				</view>
			</view>
			<view class="content">
				<view class="wrap">
					<view class="title">
						登录
					</view>
					<view class="inp">
						<view class="name">
							账号
						</view>
						<input placeholder="输入手机号" type="text" v-model="mobile" value="" />
					</view>
					<view class="inp">
						<view class="name">
							密码
						</view>
						<input placeholder="输入密码" type="password" v-model="password" value="" />
					</view>
					<view class="save" @click="login">
						登录
					</view>
				</view>
			</view>
		</view>
	</view>
	
</template>

<script>
	import http from '../../api/http.js'
	export default {
		data() {
			return {
				mobile:'',
				password:''
			}
		},
		methods: {
			toLogin(){
				uni.redirectTo({
					url:'/pages/home/home'
				})
			},
			login(){
				let data = {
					username:this.mobile,
					password:this.password
				}
				// http.post('app/login',data).then(res=>{
					
				// })
				uni.request({
					url:'http://175.27.159.73:8099/monitor-platform/app/login',
					method:'POST',
					dataType:'json',
					header: {
					        'Content-Type': 'application/json' //自定义请求头信息
					    },
					data:data,
					success:(res=>{
						console.log(res,"返回参数")
						
						if(res.data.code=='0'){
							let uniModule = uni.requireNativePlugin('EZUI-VideoView_EZModule')
							uni.setStorageSync('token',res.data.token)
							uni.setStorageSync('userId',res.data.userId)
							
							uniModule.initEzSdk('3924992889624d38806a99b880c2d0cf',true,true);
							uniModule.setAccessToken('at.c1pqjohwaabpd54saafywthaadoyp3yt-4n6ettmcms-1t9f7wm-ktymxavha')
							uni.redirectTo({
								url:'/pages/home/home'
							})
						}else{
							uni.showToast({
								title:'登录失败',
								icon:'none'
							})
						}
					})
				})
			}
		}
	}
</script>
<style>
	.status_bar {
		height: var(--status-bar-height);
		width: 100%;
		background-color: #FFFFFF;
	}
</style>
<style lang="less" scoped>
.home-index{
	width: 100vw;
	height: calc(100vh - var(--status-bar-height));
	// background-color: red;
	display: flex;
	.logo{
		display: flex;
		flex-direction: column;
		flex: 1;
		justify-content: center;
		align-items: center;
		font-size: 24px;
		font-weight: bold;
		box-shadow: 2px 2px 4px 4px rgba(232,239,247, 0.15);
		image{
			width: 80px;
			height: 80px;
			margin-bottom: 20px;
		}
	}
	.content{
		display: flex;
		justify-content: center;
		align-items: center;
		flex:1;
		background-color: #E8EFF7;
		.wrap{
			display: flex;
			flex-direction: column;
			width: 80%;
			.title{
				font-size: 24px;
				font-weight: bold;
				margin-bottom: 20px;
			}
			.inp{
				display: flex;
				flex-direction: column;
				// align-items: center;
				margin-bottom: 10px;
				// height: 50px;
				
				.name{
					display: flex;
					align-items: center;
					font-size: 18px;
					// padding: 0 10px;
					margin-bottom: 5px;
				}
				input{
					display: flex;
					border:1px solid #098ACE;
					// flex:1;
					height: 50px;;
					border-radius: 5px;
					background-color: white;
					padding: 0 10px;
					font-size: 18px;
				}
			}
			.save{
				background-color: #098ACE;
				height: 40px;
				display: flex;
				justify-content: center;
				align-items: center;
				color: white;
				font-size: 20px;
				font-weight: bold;
				border-radius: 5px;
			}
		}
	}
}
</style>
